<template>
  <div class="container">
    <div class="app-container">
      <el-button class="btn-add" size="mini" type="primary">添加权限</el-button>
   <el-table default-expand-all :data="list" row-key="id">
    <el-table-column prop="name" label="名称"></el-table-column>
    <el-table-column  prop="code"   label="标识"></el-table-column>
    <el-table-column  prop="description"   label="描述"></el-table-column>
    <el-table-column   label="操作">
      <template v-slot="{row}">
        <!-- 当 row.type 的值为 1 时，显示一个迷你型的文本按钮，按钮文本为 "添加"。
如果 row.type 不是 1，则该按钮不会渲染。 -->
      <el-button  v-if="row.type===1" size="mini" type="text">添加</el-button>
      <el-button size="mini" type="text">编辑</el-button>
      <el-button size="mini" type="text">删除</el-button>
    </template>
    </el-table-column>

   </el-table>
    </div>
  </div>
</template>

<script>
import {getPermissionList} from '@/api/permission'
import {transListToTreeData} from '@/utils'
export default {
  name: 'Permission',
  data(){
    return{
list:[]
    }
  },
  created(){
   this.getPermissionList()
  },methods:{
   async getPermissionList(){
   const result=transListToTreeData(await getPermissionList(),0)
    this.list=result

   
    }
  }
}
</script>
<style>
.btn-add{
  margin:10px
}
</style>

